package com.wjb.xietong.ota;


import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageSwitcher;

import com.wjb.xietong.R;

/**
 * 进度对话框
 * @author ZOEICER
 */
public class DialogProgress extends AlertDialog{
	private Handler handler = new Handler();
	/**动画*/
	AnimationDrawable anim;
	/**图片切换器*/
	ImageSwitcher imageSwitcher;

	public DialogProgress(Context context) {
		super(context);
		// TODO Auto-generated constructor stub	
	}
	
	public DialogProgress(Context context, int style) {
		super(context, style);
		// TODO Auto-generated constructor stub	
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_progress_layout);
		imageSwitcher = (ImageSwitcher)findViewById(R.id.image_switcher);
//		handler.postDelayed(new Runnable(){
//			@Override
//			public void run()
//			{
//				/*动画为图片切换器的帧动画*/
//				anim = (AnimationDrawable)imageSwitcher.getBackground();
//				anim.start();//开始动画
//			}
//		}, 50);
		anim = (AnimationDrawable)imageSwitcher.getBackground();
	} 
	
	
	
	@Override
	public void show() {
		// TODO Auto-generated method stub
		super.show();
		if(anim != null){
			anim.start();
		}
	}

	@Override
	public void dismiss() {
		// TODO Auto-generated method stub
		super.dismiss();
		if(anim != null){
			anim.stop();//停止动画
		}
	}
}